// pages/my/my.js
var util = require("../../utils/util.js");
import moment from '../../utils/moment.js'
var app = getApp()
Page({
  data: {
    userPic:'',
    userName:'',
    userPhone:'',
    accountId:'',
    //订单状态
    memInfo:{
        // waitPAy:2,
        waitDeliver:0,
        deliver:0,
        refund:0,
        addStock:10
      },
    todayTurnovers:{
      service: "200.23"//本月维修人工费
    },
    cash:'',
    cash_in:''
  },
  onLoad: function (options) {
    var that = this
    app.getMemInfo().then(res=>{
      this.setData({
        userPhone:res.data.username,
        accountId:res.data.id
      })
      this.getTurnover(res.data.id)
    })
    wx.getUserInfo({
      success(res){
        that.setData({
          userPic:res.userInfo.avatarUrl,
          userName:res.userInfo.nickName
        })
      }
    })
    // wx.request({
    //   url:'http://192.168.1.29:8080/wx_app/agent/cashier',
    //   data:{
    //     accountId:'1'
    //   },
    //   success(res){

    //     console.log(res.data.data)
    //     that.setData({
    //       cash:res.data.data.cash,
    //       cash_in:res.data.data.cash_in
    //     })
    //   }
    // })
  },
  //营业额
  getTurnover(accountId){
    var data = {
      accountId
    }
    app.request('wx_app/agent/cashier',data,'GET').then(res=>{
      console.log(res)
    })
  },
  //进货
  waitPayTap:function(){
    wx.navigateTo({
      url: 'purchase/purchase'
    })
  },
  //待付款
  waitePay: function () {
    wx.navigateTo({
      url: 'orders/orders?title=待付款&orderType=' + 1,
    })
  },
  //待发货
  waitDeliverTap: function () {
    wx.navigateTo({
      url: 'orders/orders?title=待发货&orderType=' + 2,
    })
  },
  //已发货
  deliverTap: function () {
    wx.navigateTo({
      url: 'orders/orders?title=已发货&orderType=' + 3,
    })
  },
  //退款/售后
  refundTap: function () {
    wx.navigateTo({
      url: 'orders/orders?title=退款/售后&orderType=' + 5,
    })
  },
  //加入库存
  addStockTap: function () {
    wx.navigateTo({
      url: 'addStock/addStock'
    })
  },
  //营业额更多
  moreTurnoverTap(event) {
    wx.navigateTo({
      url: 'turnover/turnover'
    })
  },
  //客户订单
  totalOrdersTap: function () {
    wx.navigateTo({
      url: 'orders/orders?title=客户订单&orderType=' + 0,
    })
  },
  //地址管理
  addressTap: function () {
    wx.navigateTo({
      url:"address/address",
    })
    
  },
  //设置
  setTap(event) {
    wx.navigateTo({
      url: 'set/set'
    })
  },
  storeAccountTap:function(event){
    wx.navigateTo({
      url: 'shopAccount/shopAccount',
    })
  },
  stockManageTap :function(event){
    wx.navigateTo({
      url: 'stockManage/stockIndex',
    })
  },
  toMyWallet(){
    wx.navigateTo({
      url:'myWallet/myWallet'
    })
  }

})